home *** CD-ROM | disk | FTP | other *** search
- /* AddressOMatic.h */
- /*
- * AddressOMatic
- * AddressOMatic.h
- * Copyright © 1993 Apple Computer Inc. All rights reserved.
- * AddressOMatic is a Trademark of Apple Computer Inc.
- *
- * These are the public definitions for the AddressOMatic.
- */
- #ifndef _AddressOMatic_
- #define _AddressOMatic_
- #ifndef THINK_C /* MPW includes */
- #include <Menus.h>
- #include <TextEdit.h>
- #include <Types.h>
- #include <Windows.h>
- #endif
- #include <OCE.h>
- #include <OCEAuthDir.h>
- #include <OCEStandardDirectory.h>
- #include <OCEErrors.h>
-
- /*
- * Define ENABLE_TYPEIN to get type-in definitions. If undefined, no typein
- * processing is provided whatsoever. I.e., string definitions must be changed.
- * Note: MPW Rez does not process #if ENABLE_TYPEIN
- */
- // #undef ENABLE_TYPEIN
- #define ENABLE_TYPEIN
-
- /*
- * This "random" number is used to create the type-in popup menu. It defines
- * the start of a range of numbers (one for each open window).
- * The user application must not create a menu with this menu id value
- * or any value slightly larger as one higher value is consumed for each
- * window that is opened.
- */
- #define kAOMPrivateMenuID 11640 /* Useless random number */
- /*
- * 'STR#' stringsResID (parameter to NewSDPPanel)
- * These index strings that we need for help text etc. The application must
- * provide a STR# resource with the necessary text.
- */
- enum {
- /*
- * Pane title strings (9 pt Geneva bold, centered)
- */
- kAOMPDTitleString = 1, /* "Personal Catalog" */
- kAOMPanelTitleString, /* "Catalog Browser" */
- kAOMFindTitleString, /* "Find Address" */
- /*
- * Button strings for the AOM selection buttons.
- * The "Done" button is always enabled. If you put the AddressOMatic in
- * its own window, you can eliminate this button and use a close box instead.
- * The "Done" button does not interact with the SDP browser panels.
- */
- kAOMDoneButtonString, /* "Done" <Opt> etc. ignored */
- /*
- * The "To" button has many manifestations. In the following, "(unchanged)"
- * means that the button text is not modified. I.e., if you select a folder
- * in the browser, then click on "nothing" the To button is disabled, but
- * still shows "Save".
- * Browser, Personal Directory, and Type-In Panel
- * Selection Option Button Text Enabled
- * Nothing Off (unchanged) No
- * Nothing On (unchanged) No
- * Folder Off "Open" Yes
- * Folder On "Save" Yes
- * Record Off "To" Yes
- * Record On "Save" Yes
- * Find Panel
- * Selection Option Button Text Enabled
- * Nothing Any (unchanged) No
- * Has Find Text Any, Stopped "Find" Yes
- * Has Find Text Any, Finding "Stop" Yes
- * Has Selection Off, Stopped "To" Yes
- * Has Selection On, Stopped "Save" Yes
- */
- kAOMToButtonString, /* "To" <Opt> off, record selected */
- kAOMOpenButtonString, /* "Open" <Opt> off, folder selected */
- kAOMSaveButtonString, /* "Save" <Opt> on, item selected */
- kAOMFindButtonString, /* "Find" <Opt> ignored */
- kAOMStopButtonString, /* "Stop" <Opt> ignored */
- /*
- * The "CC" button has two manifestations. It is enabled if the "To" button
- * shows "To" or "Save" and is enabled if a record is selected. It is disabled
- * if the panel is currently finding (the "To" button shows "Find" or "Stop").
- */
- kAOMCCButtonString, /* "CC" <Opt> off, record selected */
- kAOMOptCCButtonString, /* "BCC" <Opt> on, record selected */
- /*
- * Find panel item labels
- */
- kAOMFindArgLabelString, /* "Find" */
- kAOMFindDirLabelString, /* "Search" */
- #ifdef ENABLE_TYPEIN
- kAOMTypeInTitleString, /* "Type-in Addressing" */
- kAOMTypeInAddrLabelString, /* "Address" */
- kAOMTypeInDirLabelString, /* "Catalog" */
- #endif
- /*
- * Personal Directory has no labels
- */
- kAOMLastString
- };
-
- /*
- * These mode bits configure the Address-O-Matic panel: If a radio button (PD,
- * Panel, Show, TypeIn) is disabled, it is shown, but always disabled. If one of
- * the action buttons (Done, CC, To) is not shown, it is not shown (and not
- * available). It might make sense, however, to allow configuring the panel with
- * missing radio buttons, but this brings up positioning issues I'd rather avoid.
- *
- * kAOMEnablePDBit, kAOMEnablePanelBit, kAOMEnableFindBit, kAOMEnableTypeInBit
- * and kAOMUnknownMode are also used for the initial radio button mode.
- */
- enum {
- kAOMUnknownMode = 0xFFFF,
- kAOMEnablePDBit = 0,
- kAOMEnablePanelBit,
- kAOMEnableFindBit,
- #ifdef ENABLE_TYPEIN
- kAOMEnableTypeInBit,
- #endif
- kAOMShowDoneButtonBit,
- kAOMShowCCButtonBit,
- kAOMShowToButtonBit
- };
- typedef unsigned short AOMModeBit;
-
- enum {
- kAOMEnablePDMask = (1L << kAOMEnablePDBit),
- kAOMEnablePanelMask = (1L << kAOMEnablePanelBit),
- kAOMEnableFindMask = (1L << kAOMEnableFindBit),
- #ifdef ENABLE_TYPEIN
- kAOMEnableTypeInMask = (1L << kAOMEnableTypeInBit),
- #endif
- kAOMShowDoneButtonMask = (1L << kAOMShowDoneButtonBit),
- kAOMShowCCButtonMask = (1L << kAOMShowCCButtonBit),
- kAOMShowToButtonMask = (1L << kAOMShowToButtonBit),
- #ifdef ENABLE_TYPEIN
- kAOMAllRadioButtons = (
- kAOMEnablePDMask
- | kAOMEnablePanelMask
- | kAOMEnableFindMask
- | kAOMEnableTypeInMask
- ),
- kAOMStandardRadioButtons = ( /* "Standard" excludes the type-in button */
- kAOMEnablePDMask
- | kAOMEnablePanelMask
- | kAOMEnableFindMask
- ),
- #else
- kAOMAllRadioButtons = (
- kAOMEnablePDMask
- | kAOMEnablePanelMask
- | kAOMEnableFindMask
- ),
- kAOMStandardRadioButtons = ( /* "Standard" excludes the type-in button */
- kAOMEnablePDMask
- | kAOMEnablePanelMask
- | kAOMEnableFindMask
- ),
- #endif
- kAOMAllActionButtons = (
- kAOMShowDoneButtonMask | kAOMShowCCButtonMask | kAOMShowToButtonMask
- )
- };
- typedef unsigned long AOMModeMask;
-
- /*
- * Index for item rectangles in the AOM panel. This is needed for Help strings,
- * as well as mouse hits. Note that item 1 corresponds to Help item 1, etc. The
- * application program does not need to be concerned with this information: it
- * is used internally, but is defined here to allocate the proper amount of
- * memory.
- */
- typedef enum {
- kAOMPanelItem = 0,
- kAOMPDButtonItem,
- kAOMFirstRadio = kAOMPDButtonItem,
- kAOMDirButtonItem,
- kAOMFindButtonItem,
- #ifdef ENABLE_TYPEIN
- kAOMTypeInButtonItem,
- kAOMLastRadio = kAOMTypeInButtonItem,
- #else
- kAOMLastRadio = kAOMFindButtonItem,
- #endif
- kAOMRadioButtons = kAOMLastRadio - kAOMFirstRadio + 1,
- kAOMDoneButtonItem = kAOMLastRadio + 1,
- kAOMFirstButton = kAOMDoneButtonItem,
- kAOMCCButtonItem,
- kAOMToButtonItem,
- kAOMLastButton = kAOMToButtonItem,
- kAOMSDPPanelItem,
- kAOMSDPPanelExterior, /* SDP stuff with slop for focus rect */
- #ifdef ENABLE_TYPEIN
- kAOMTypeInAddrLabelItem, /* "Address" */
- kAOMTypeInDirLabelItem, /* "Directory" */
- kAOMTypeInAddressItem, /* Address TextEdit record */
- kAOMTypeInDirectoryItem, /* Directory popup control */
- #endif
- kAOMSpinnerItem,
- kAOMPanelLabelItem,
- kAOMInteriorAreaItem, /* Inside of the drop shadow */
- kAOMItemRectCount
- } AOMItemIndex;
-
- /*
- * These are the values for the AOMPanelEvent "whatHappened" parameter. This
- * is a synthesis of Standard Mail and Standard Directory event processing.
- * These are bit numbers. The application should use the mask values below.
- *
- * kAOMAppMustHandleEventBit
- * If TRUE, the application must process this event. It may also have
- * been processed by the AOM Panel.
- * kAOMPanelBecomesTargetBit
- * The user clicked in the AOM Panel. kAOMAppMustHandleEventBit is FALSE,
- * but the application may wish to handle this event by un-hiliting
- * window selections or stopping insertion point blinking.
- * kAOMAppBecomesTargetBit
- * The user was working in the AOM Panel, but now clicked in the window
- * content area (outside of the AOM Panel). kAOMAppMustHandleEventBit is
- * set TRUE.
- * kAOMFindInProgressBit
- * The AOM Panel is currently finding. You should set a lower WaitNextEvent
- * sleep time to give the panel more time to search.
- * kAOMSelectedAnItemBit
- * The AOM Panel is processing a Standard Directory Browser panel. This
- * bit is set if the call to SDPPanelEvent returned kSDPSelectedAnItem.
- * kAOMChangedSelectionBit
- * The AOM Panel is processing a Standard Directory Browser panel. This
- * bit is set if the call to SDPPanelEvent returned kSDPChangedSelection.
- * kAOMItemIsSelectedBit
- * The AOM Panel is processing a Standard Find panel. This bit is set if
- * the call to SDPFindPanelState set kSDPItemIsSelectedBit.
- * kAOMFindTextExistsBit
- * The AOM Panel is processing a Standard Find panel. This bit is set if
- * the call to SDPFindPanelState set kSDPFindTextExistsBit.
- * kAOMDoneButtonHitBit
- * kAOMCCButtonHitBit
- * kAOMBCCButtonHitMask
- * kAOMToButtonHitBit
- * kAOMSaveButtonHitMask
- * The associated button was pressed; kAOMAppMustHandleEventBit is set TRUE.
- */
- enum {
- kAOMAppMustHandleEventBit, /* App ignores event if FALSE */
- kAOMPanelBecomesTargetBit, /* Click in AOM Panel */
- kAOMAppBecomesTargetBit, /* Click outside AOM Panel */
- kAOMFindInProgressBit, /* Currently finding */
- kAOMSelectedAnItemBit, /* kSDPSelectedAnItem */
- kAOMChangedSelectionBit, /* kSDPChangedSelection */
- kAOMDoneButtonHitBit, /* User hit "done" */
- kAOMCCButtonHitBit, /* User hit "cc" */
- kAOMBCCButtonHitBit, /* User hit <OPT> "cc" */
- kAOMToButtonHitBit, /* User hit "to" */
- kAOMSaveButtonHitBit /* User hit <OPT> "To" */
- };
- /*
- * The application should use the following mask bits to test event state.
- * These are #defines to avoid Ansi C "enums are int" problems.
- */
- #define kAOMAppMustHandleEventMask (1L << kAOMAppMustHandleEventBit)
- #define kAOMPanelBecomesTargetMask (1L << kAOMPanelBecomesTargetBit)
- #define kAOMAppBecomesTargetMask (1L << kAOMAppBecomesTargetBit)
- #define kAOMFindInProgressMask (1L << kAOMFindInProgressBit)
- #define kAOMSelectedAnItemMask (1L << kAOMSelectedAnItemBit)
- #define kAOMChangedSelectionMask (1L << kAOMChangedSelectionBit)
- #define kAOMDoneButtonHitMask (1L << kAOMDoneButtonHitBit)
- #define kAOMCCButtonHitMask (1L << kAOMCCButtonHitBit)
- #define kAOMBCCButtonHitMask (1L << kAOMBCCButtonHitBit)
- #define kAOMToButtonHitMask (1L << kAOMToButtonHitBit)
- #define kAOMSaveButtonHitMask (1L << kAOMSaveButtonHitBit)
- #define kAOMAnyActionButtonHitMask ( \
- kAOMCCButtonHitMask \
- | kAOMBCCButtonHitMask \
- | kAOMToButtonHitMask \
- | kAOMSaveButtonHitMask \
- )
-
- typedef unsigned long AOMPanelState;
-
- /*
- * This is the information the AddressOMatic needs to process user requests.
- * Some of this information persists between calls. Although this is
- * visible to applications, it should be treated as a private structure
- * (i.e., applications should call functions to manage data, rather than
- * change it directly).
- */
- typedef struct AddressOMaticRecord {
- WindowPtr window; /* The AOM is in this window */
- SDPPanelHandle pdPanel; /* -> Personal Directory Panel */
- SDPPanelHandle browsePanel; /* -> SDP panel, if any */
- SDPFindPanelHandle findPanel; /* -> Find panel, if any */
- SDPSelectionState browseSelectionState; /* Browser state */
- SDPFindPanelState findPanelState; /* Find state */
- SDPSelectionState oldBrowseSelectionState; /* Previous browser state */
- SDPFindPanelState oldFindPanelState; /* Previous find state */
- /*
- * Button controls. The radio buttons that select what is displayed are
- * handled internally.
- */
- ControlHandle doneButton; /* "done" */
- ControlHandle ccButton; /* "cc" or "bcc" */
- ControlHandle toButton; /* "to" or "save" */
- #ifdef ENABLE_TYPEIN
- RStringPtr typeInRecordType; /* What does type-in return? */
- ControlHandle typeInPopup; /* Directories popup CDEF */
- TEHandle typeInAddress; /* Address text */
- MenuHandle popupMenu; /* Private menu handle */
- short popupMenuID; /* Private menu id */
- Boolean typeInVisible; /* TRUE if stuff is on screen */
- struct _AOMDirectoryInfoRecord (**dirInfoHdl); /* Our directories */
- #endif
- AuthIdentity identity; /* Needed for type-in only */
- const RStringPtr *typesList; /* Active types */
- unsigned long typeCount; /* Number of active types */
- void *refCon; /* User-controlled value */
- /*
- * These variables manage the "in progress" spinner.
- */
- short animationSICNIndex; /* Current animation SICN */
- unsigned long nextAnimation; /* When to update animation */
- /*
- * These values manage active operation state.
- */
- Boolean isVisible; /* AOM is currently visible */
- Boolean isEnabled; /* AOM is currently active */
- Boolean isTarget; /* User clicked in AOM Panel */
- AOMModeBit currentMode; /* What is the user doing now? */
- short optKeyDown; /* Last event set option key */
- Boolean buttonUpdateNeeded; /* TRUE updates action buttons */
- Boolean enableToButton; /* TRUE if to button is alive */
- Boolean enableCCButton; /* TRUE if cc button is alive */
- short toButtonString; /* String index of "To" button */
- short ccButtonString; /* String index of "CC" button */
- short stringsResID; /* Where are our strings */
- Boolean helpAvailable; /* Is Balloon Help present? */
- Boolean radioEnable[kAOMRadioButtons]; /* TRUE if enabled */
- /*
- * This Rect vector manages the shape of the panel and all its elements.
- * The zero'th item is the panel rectangle. All values are in Window
- * coordinates. If the panel moves within the window, all items must be offset.
- */
- Rect itemRect[kAOMItemRectCount]; /* Panel and item layout */
- } AddressOMaticRecord, *AddressOMaticPtr;
-
- /*
- * Create an AddressOMatic panel. If the application disables one of the
- * radio buttons, it should pass NULL or zero for the affected parameter.
- */
- pascal OSErr AOMNewPanel(
- AddressOMaticPtr *aomPanel, /* Record stored here */
- WindowPtr window, /* Put into this window */
- const Rect *bounds, /* Shape and position */
- Boolean visible, /* Initially visible */
- Boolean enabled, /* Initially enabled */
- AuthIdentity identity, /* Initial identity */
- const RStringPtr *typesList, /* Types to select */
- unsigned long typeCount, /* Number of types */
- void *refCon, /* App owns this value */
- AOMModeMask enableModeMask, /* What can user do? */
- AOMModeBit initialMode, /* Starting with? */
- short stringsResID, /* Labelling strings */
- short browserHelpStringID, /* Browser help string */
- short pdHelpStringID, /* Personal Cat. help */
- short findHelpStringID, /* Find panel help */
- /*
- * The following parameters configure the SDPPanel and Personal Directory
- * Browser.
- */
- const PackedRLI *initialRLI, /* Initial selection */
- DirEnumChoices enumFlags, /* Enumeration flags */
- DirMatchWith matchTypeHow, /* Enumeration mode */
- /*
- * The following parameter configures the SDPFindPanel. Focus is always
- * initially in the text area.
- */
- short simultaneousSearchCount
- #ifdef ENABLE_TYPEIN
- ,
- /*
- * The following parameter configures the TypeIn callback
- */
- const RStringPtr typeInRecordType /* What does it return */
- #endif
- );
-
-
- /*
- * Return the minimum width and height of the panel. The panel need not
- * have been created. This function does not have an error status.
- */
- void AOMGetDimensions(
- short *minimumWidth,
- short *minimumHeight
- );
- /*
- * Clean up the mess.
- */
- pascal OSErr AOMDisposePanel(
- AddressOMaticPtr aomPanel /* The panel */
- );
-
- /*
- * Redraw the panel. Called on update events. Set drawRgn to NULL
- * to redraw the entire panel. Normally, it is set to the window's
- * GrafPort's visRgn.
- */
- pascal OSErr AOMUpdatePanel(
- AddressOMaticPtr aomPanel,
- RgnHandle drawRgn
- );
-
- pascal OSErr AOMAdjustPanel(
- AddressOMaticPtr aomPanel,
- const Rect *boundsRect
- );
- /*
- * TBS:
- * Set identity
- * Set Path, Get Path, Get Path Length
- * Set SDP Panel Balloon Help
- * Set SDP Panel Find Help
- * Set SDP Type In Help (Dialog help format)
- * Become Target (for tabbing, param is "select Last"
- * or "select first") -- this is needed because the
- * number of active elements may change depending on
- * the radio button state. We can't allow the application
- * to select a random target.
- */
-
- /*
- * AOMExtractSelection does all the work of getting the current selection.
- * On return:
- * result error code from OCE, or kOCENoSuchRecord if there is
- * no current selection.
- * selectionSize contains the size of the buffer that was created.
- * selection The address of a PackedDSSpecPtr that, on return,
- * will contain a pointer to the selection.
- */
- pascal OSErr AOMExtractSelection(
- AddressOMaticPtr aomPanel,
- unsigned short *selectionSize,
- PackedDSSpecPtr *selection
- );
- /*
- * Call on every event
- */
- pascal OSErr AOMPanelEvent(
- AddressOMaticPtr aomPanel, /* The panel */
- const EventRecord *theEvent, /* The event */
- AOMPanelState *whatHappened /* Result */
- );
-
- /*
- * This should be done by using the identity queue instead.
- */
- pascal OSErr AOMSetIdentity(
- AddressOMaticPtr aomPanel, /* The panel */
- AuthIdentity userIdentity
- );
-
- #endif /* _AddressOMatic_ */
-